<template>
	<view class="flex flex-wrap padding-sm justify-between">
		<goods-item v-for="item in cakeList" :good-data="item"/>
	</view>
</template>

<script>
import { cakeGet } from '../../api/cake';
	export default {
		data() {
			return {
				cakeList:[],
				page:0
			};
		},
		async onLoad() {
			let res = await cakeGet()
			this.cakeList = res.data.results
			this.page++
		},
		onReachBottom() {
			console.log("触底了");
			cakeGet(this.page).then(res=>{
				let {results} = res.data
				if(results.length){
					this.cakeList = [
						...this.cakeList,
						...results
					]
					this.page++
					return
				}
				uni.showToast({
					title:"没有更多数据了",
					icon:"none"
				})
			})
		}
	}
</script>

<style lang="scss">

</style>
